{% extends 'pet_admin/base.html'%}

{% block main_body %}
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
      用户管理
      <small>幻兽商城后台</small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="{% url 'admin_index' %}"><i class="fa fa-dashboard"></i> 首页</a></li>
      <li class="active">用户管理</li>
    </ol>
  </section>

  <!-- Main content -->
  <section class="content container-fluid">

    <div class="row">
      <div class="col-xs-12">
        <div class="box">
          <div class="box-header">
            <h3 class="box-title">用户信息表</h3>

            <div class="box-tools">
              <form action="{% url 'admin_find' 1 %}" method="get">
                <div class="input-group input-group-sm" style="width: 150px;">
                  <input type="text" name="searchKey" class="form-control pull-right" placeholder="ID/昵称">

                  <div class="input-group-btn">
                    <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
                  </div>
                </div>
              </form>
            </div>

          </div>
          <!-- /.box-header -->
          <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
              <tr>
                <th>用户ID</th>
                <th>用户名称</th>
                <th>用户类型</th>
                <th>用户状态</th>
                <th>用户积分</th>
                <th>注册时间</th>
                <th>修改时间</th>
                <th>操作</th>
              </tr>
              {% for user in users %}
              <tr>
                <td>{{ user.user_id }}</td>
                <td>{{ user.user_name }}</td>
                <td>
                  {% if user.user_type == 0 %}
                    <span style="color:blue">店主</span>
                  {% elif user.user_type == 1 %}
                    <span style="color:#873324">代理</span>
                  {% elif user.user_type == 2 %}
                    <span style="color:#8A2BE2">VIP</span>
                  {% elif user.user_type == 8 %}
                    <span style="color:green">普通用户</span>
                  {% elif user.user_type == 9 %}
                    <span style="color:red">黑名单</span>
                  {% else %}
                    特殊用户
                  {% endif %}
                </td>
                <td>
                  {% if user.user_status == 0 %}
                    <span style="color:green">正常</span>
                  {% elif user.user_type == 9 %}
                    <span style="color:red">禁用</span>
                  {% else %}
                    特殊用户
                  {% endif %}
                </td>
                <td>
                  {% if user.user_integral == None %}
                    0
                  {% else %}
                    {{ user.user_integra }}
                  {% endif %}
                </td>
                <td>{{ user.user_createtime|date:'Y-m-d' }}</td>
                <td>
                  {{ user.user_updatetime|date:'Y-m-d' }}
                </td>
                <td>
                  <a type="button" class="btn btn-success btn-xs" href="{% url 'admin_edit' user.user_id %}">
                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 编辑</a>
                  {% if user.user_type == 2 %}
                  <button type="button" onclick="doAgent('{% url 'admin_agent' user.user_id %}')" class="btn btn-primary btn-xs" >
                    <span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span> 升级代理</button>
                  {% elif user.user_type == 1 %}
                  <button type="button" onclick="doVip('{% url 'admin_dovip' user.user_id %}')" class="btn btn-primary btn-xs" >
                    <span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span> 降级为VIP</button>
                  {% endif %}
                  <button type="button" onclick="doDel('{% url 'admin_del' user.user_id %}')" class="btn btn-danger btn-xs">
                    <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> 删除</button>

<!--                  <button type="button" class="btn btn-warning btn-xs">-->
<!--                    <span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查看订单</button>-->
                </td>
              </tr>
              {% endfor %}
            </table>
          </div>
          <!-- /.box-body -->
          <div class="box-footer clearfix">
            <a role="button" href="{% url 'admin_add' %}" class="btn btn-primary">
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加用户</a>
            <ul class="pagination pagination-sm no-margin pull-right">
              <li><a href="{% if pageIndex != 1 %}{% url 'admin_find' pageIndex|add:-1 %}?{{ searchKey|join:'&' }} {% endif %}">&laquo;</a></li>
                {% for page in pages %}
                  <li {% if page == pageIndex %} class = "active" {% endif %}><a href="{% url 'admin_find' page %}?{{ searchKey|join:'&' }}">{{ page }}</a></li>
                {% endfor %}
              <li><a href="{% if pageIndex != maxPage %}{% url 'admin_find' pageIndex|add:1 %}?{{ searchKey|join:'&' }} {% endif %}">&raquo;</a></li>
            </ul>
          </div>
        </div>
        <!-- /.box -->
      </div>
    </div>

  </section>
  <!-- /.content -->
{% endblock %}